<?php class Universes { 

    /***
     * DB Fields: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id;

    /***
     * DB Fields: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $name;

    /***
     * DB Fields: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $description;

    /***
     * DB Fields: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $image;

    /***
     * DB Fields: charId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $charId;

    /***
     * DB Fields: chapter
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $chapter;

    /***
     * DB Fields: openForRegistration
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $openForRegistration;

    /***
     * DB Fields: maxUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $maxUsers;

    /***
     * DB Fields: currentUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $currentUsers;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id
     **/
    function get_id( ) {
        // returns the value of id
        return $this->id;
    }


    /***
     * Get value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result name
     **/
    function get_name( ) {
        // returns the value of name
        return $this->name;
    }


    /***
     * Get value for field: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result description
     **/
    function get_description( ) {
        // returns the value of description
        return $this->description;
    }


    /***
     * Get value for field: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result image
     **/
    function get_image( ) {
        // returns the value of image
        return $this->image;
    }


    /***
     * Get value for field: charId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result charId
     **/
    function get_charId( ) {
        // returns the value of charId
        return $this->charId;
    }


    /***
     * Get value for field: chapter
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result chapter
     **/
    function get_chapter( ) {
        // returns the value of chapter
        return $this->chapter;
    }


    /***
     * Get value for field: openForRegistration
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result openForRegistration
     **/
    function get_openForRegistration( ) {
        // returns the value of openForRegistration
        return $this->openForRegistration;
    }


    /***
     * Get value for field: maxUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result maxUsers
     **/
    function get_maxUsers( ) {
        // returns the value of maxUsers
        return $this->maxUsers;
    }


    /***
     * Get value for field: currentUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result currentUsers
     **/
    function get_currentUsers( ) {
        // returns the value of currentUsers
        return $this->currentUsers;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function set_id( $id ) {
        // sets the value of id
        $this->id = $id;
    }

    /***
     * Set value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param name
     * @result void
     **/
    function set_name( $name ) {
        // sets the value of name
        $this->name = $name;
    }

    /***
     * Set value for field: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param description
     * @result void
     **/
    function set_description( $description ) {
        // sets the value of description
        $this->description = $description;
    }

    /***
     * Set value for field: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param image
     * @result void
     **/
    function set_image( $image ) {
        // sets the value of image
        $this->image = $image;
    }

    /***
     * Set value for field: charId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param charId
     * @result void
     **/
    function set_charId( $charId ) {
        // sets the value of charId
        $this->charId = $charId;
    }

    /***
     * Set value for field: chapter
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param chapter
     * @result void
     **/
    function set_chapter( $chapter ) {
        // sets the value of chapter
        $this->chapter = $chapter;
    }

    /***
     * Set value for field: openForRegistration
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param openForRegistration
     * @result void
     **/
    function set_openForRegistration( $openForRegistration ) {
        // sets the value of openForRegistration
        $this->openForRegistration = $openForRegistration;
    }

    /***
     * Set value for field: maxUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param maxUsers
     * @result void
     **/
    function set_maxUsers( $maxUsers ) {
        // sets the value of maxUsers
        $this->maxUsers = $maxUsers;
    }

    /***
     * Set value for field: currentUsers
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param currentUsers
     * @result void
     **/
    function set_currentUsers( $currentUsers ) {
        // sets the value of currentUsers
        $this->currentUsers = $currentUsers;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: universes
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param name
     * @param description
     * @param image
     * @param charId
     * @param chapter
     * @param openForRegistration
     * @param maxUsers
     * @param currentUsers
     * @result void
     **/
    function createnew_universes( $id, $name, $description, $image, $charId, $chapter, $openForRegistration, $maxUsers, $currentUsers ) {

        // items to be inserted in the database 
        $_obj = array($id,
                      $name,
                      $description,
                      $image,
                      $charId,
                      $chapter,
                      $openForRegistration,
                      $maxUsers,
                      $currentUsers); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("universes", $_obj);
    }

    /***
     * Retrived an existing record: universes
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result new Universes
     **/
    function get_universes( $id ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM universes WHERE id = '$id'");

        $__universesObj = new universes();
        // return the retrived from the database

        // create a new object
        $__obj = new Universes();
        $__obj->set_id($_resultSet[0]['id']);
        $__obj->set_name($_resultSet[0]['name']);
        $__obj->set_description($_resultSet[0]['description']);
        $__obj->set_image($_resultSet[0]['image']);
        $__obj->set_charId($_resultSet[0]['charId']);
        $__obj->set_chapter($_resultSet[0]['chapter']);
        $__obj->set_openForRegistration($_resultSet[0]['openForRegistration']);
        $__obj->set_maxUsers($_resultSet[0]['maxUsers']);
        $__obj->set_currentUsers($_resultSet[0]['currentUsers']);


        return $__obj;
    }

    /***
     * Update an existing record: universes
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_universes( $id, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("universes", "id = '$id'");
    }

    /***
     * Delete an existing record: universes
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function delete_universes( $id ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("universes", "id = '$id'");
    }

    /***
     * Retrived list of objects base on a given parameters: universes
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Universes
     **/
    function list_universes( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM universes WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM universes";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Universes();

            $__newObj->set_id($__rs['id']);
            $__newObj->set_name($__rs['name']);
            $__newObj->set_description($__rs['description']);
            $__newObj->set_image($__rs['image']);
            $__newObj->set_charId($__rs['charId']);
            $__newObj->set_chapter($__rs['chapter']);
            $__newObj->set_openForRegistration($__rs['openForRegistration']);
            $__newObj->set_maxUsers($__rs['maxUsers']);
            $__newObj->set_currentUsers($__rs['currentUsers']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>